all: uart_echo.elf

uart_echo.elf: uart.c entry.S linker.ld
	riscv64-unknown-elf-gcc -c -nostdlib -fno-builtin -mcmodel=medany -o uart.o uart.c
	riscv64-unknown-elf-gcc -c -nostdlib -fno-builtin -o entry.o entry.S
	riscv64-unknown-elf-ld -T linker.ld -o uart_echo.elf entry.o uart.o

run-qemu: uart_echo.elf
	qemu-system-riscv64 -M virt -nographic -bios none -kernel uart_echo.elf -serial pty

# 	screen /dev/pts/1 115200

clean:
	rm -f *.o *.elf

.PHONY: all run-qemu clean
